//
//  OCTabBarController.m
//  ocVB
//
//  Created by apple on 2016/10/23.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "OCTabBarController.h"
#import "OCNavigationController.h"
#import "OCTabBar.h"

@interface OCTabBarController ()

@end

@implementation OCTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addViews];
    
    OCTabBar *tabBar = [[OCTabBar alloc] init];
    
    [self setValue:tabBar forKey:@"tabBar"];

 }

/**
 添加子控件
 */
- (void)addViews
{
    [self className:@"OCHomeViewController" andtitle:@"首页" andimageName:@"tabbar_home"];
    [self className:@"OCMessageViewController" andtitle:@"消息" andimageName:@"tabbar_message_center"];
    [self className:@"OCDiscoverViewController" andtitle:@"发现" andimageName:@"tabbar_discover"];
    [self className:@"OCMineViewController" andtitle:@"我的" andimageName:@"tabbar_profile"];
    
}

/**
 创建导航控制

 @param className 服务器名称
 @param title     名称
 @param imgName   图片名称

 */
- (void)className:(NSString *)className andtitle:(NSString *)title andimageName:(NSString *)imgName
{
    Class cls = NSClassFromString(className);
    UIViewController *vc = [[cls alloc] init];
    vc.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:imgName];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:[imgName stringByAppendingString:@"_selected"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    OCNavigationController *nav = [[OCNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}


@end
